﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Wjtour.Domain;
using Wjtour.BLL;
using Hjp.FrameWork.Common;
using Wjtour.Common;

namespace Wjtour.Web.Admin.line
{
    public partial class list : BasePage
    {
        #region 固定分页参数
        private int page = 1;
        private int pagesize = 20;
        #endregion

        line_bll _bll = new line_bll();
        protected PaginationData<Wjtour.Domain.line> data = new PaginationData<Domain.line>();
        protected TextBox q;
        protected DropDownList cid;
        protected Button submit;
        protected HiddenField delIds;
        protected Button delButton;
        protected string type;

        protected void Page_Load(object sender, EventArgs e)
        {
            page = Utils.StrToInt(Request["page"], 1);
            submit.Click += new EventHandler(submit_Click);
            delButton.Click += new EventHandler(delButton_Click);
            bindList();
            if (!IsPostBack)
            {
                q.Text = Request["q"];
            }
        }

        void delButton_Click(object sender, EventArgs e)
        {
            bool b = _bll.BatchDelete(delIds.Value) > 0;

            if (b)
            {
                SaveLog("Delete[" + delIds.Value + "]");
                Utils.Alert(this.Page, "删除成功！");
                Utils.Redirect(this.Page, "list.aspx?q=" + q.Text, false);
            }
        }

        void submit_Click(object sender, EventArgs e)
        {
            bindList();
        }

        void bindList()
        {
            data = _bll.GetList(q.Text, page - 1, pagesize);
            PagerHtml = Utility.pageft(data.Pager.TotalRecords, "/admin/line/list.aspx?q=" + HttpUtility.UrlEncode(q.Text), pagesize);
        }
    }
}